// 餐品分类模型
import { DataTypes } from 'sequelize'
import { sequelize } from '../../db/index.js'

const FoodCategory = sequelize.define('FoodCategory', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true,
    comment: '分类ID'
  },
  name: {
    type: DataTypes.STRING(50),
    allowNull: false,
    unique: true,
    comment: '分类名称'
  },
  description: {
    type: DataTypes.STRING,
    allowNull: true,
    comment: '分类描述'
  },
  status: {
    type: DataTypes.ENUM('active', 'inactive'),
    defaultValue: 'active',
    comment: '状态：active - 启用，inactive - 禁用'
  },
  sort_order: {
    type: DataTypes.INTEGER,
    defaultValue: 0,
    comment: '排序顺序'
  }
}, {
  tableName: 'food_category',
  timestamps: true,
  paranoid: true, // 软删除
  underscored: true,
  indexes: [
    {
      name: 'idx_name',
      fields: ['name']
    }
  ]
});

export default FoodCategory;